package org.wu.framework.authorization.platform.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.wu.framework.web.spring.EasyController;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.annotation.Resource;
import java.util.List;
import org.wu.framework.authorization.platform.domain.model.sys.role.permission.SysRolePermission;
import org.wu.framework.authorization.platform.application.command.sys.role.permission.SysRolePermissionRemoveCommand;
import org.wu.framework.authorization.platform.application.command.sys.role.permission.SysRolePermissionStoryCommand;
import org.wu.framework.authorization.platform.application.command.sys.role.permission.SysRolePermissionUpdateCommand;
import org.wu.framework.authorization.platform.application.command.sys.role.permission.SysRolePermissionQueryListCommand;
import org.wu.framework.authorization.platform.application.command.sys.role.permission.SysRolePermissionQueryOneCommand;
import org.wu.framework.authorization.platform.application.SysRolePermissionApplication;
import org.wu.framework.authorization.platform.application.dto.SysRolePermissionDTO;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.authorization.platform.application.command.sys.role.permission.SysRolePermissionExcelExport;
import org.wu.framework.authorization.platform.application.command.sys.role.permission.SysRolePermissionExcelImport;
import org.wu.framework.easy.excel.stereotype.RequestExcelBody;
import org.wu.framework.easy.excel.stereotype.EasyExcel;
/**
 * describe 角色权限关系 
 *
 * @author Jia wei Wu
 * @date 2025/08/03 01:55 下午
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController 
 **/
@Tag(name = "角色权限关系提供者")
@EasyController("/sys/role/permission")
public class SysRolePermissionProvider  {

    @Resource
    private SysRolePermissionApplication sysRolePermissionApplication;

    /**
     * describe 新增角色权限关系
     *
     * @param sysRolePermissionStoryCommand 新增角色权限关系     
     * @return {@link Result<SysRolePermission>} 角色权限关系新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "新增角色权限关系")
    @PostMapping("/story")
    public Result<SysRolePermission> story(@RequestBody SysRolePermissionStoryCommand sysRolePermissionStoryCommand){
        return sysRolePermissionApplication.story(sysRolePermissionStoryCommand);
    }
    /**
     * describe 批量新增角色权限关系
     *
     * @param sysRolePermissionStoryCommandList 批量新增角色权限关系     
     * @return {@link Result<List<SysRolePermission>>} 角色权限关系新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "批量新增角色权限关系")
    @PostMapping("/batchStory")
    public Result<List<SysRolePermission>> batchStory(@RequestBody List<SysRolePermissionStoryCommand> sysRolePermissionStoryCommandList){
        return sysRolePermissionApplication.batchStory(sysRolePermissionStoryCommandList);
    }
    /**
     * describe 更新角色权限关系
     *
     * @param sysRolePermissionUpdateCommand 更新角色权限关系     
     * @return {@link Result<SysRolePermission>} 角色权限关系领域对象     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "更新角色权限关系")
    @PutMapping("/updateOne")
    public Result<SysRolePermission> updateOne(@RequestBody SysRolePermissionUpdateCommand sysRolePermissionUpdateCommand){
        return sysRolePermissionApplication.updateOne(sysRolePermissionUpdateCommand);
    }
    /**
     * describe 查询单个角色权限关系
     *
     * @param sysRolePermissionQueryOneCommand 查询单个角色权限关系     
     * @return {@link Result<SysRolePermissionDTO>} 角色权限关系DTO对象     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "查询单个角色权限关系")
    @GetMapping("/findOne")
    public Result<SysRolePermissionDTO> findOne(@ModelAttribute SysRolePermissionQueryOneCommand sysRolePermissionQueryOneCommand){
        return sysRolePermissionApplication.findOne(sysRolePermissionQueryOneCommand);
    }
    /**
     * describe 查询多个角色权限关系
     *
     * @param sysRolePermissionQueryListCommand 查询多个角色权限关系     
     * @return {@link Result<List<SysRolePermissionDTO>>} 角色权限关系DTO对象     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "查询多个角色权限关系")
    @GetMapping("/findList")
    public Result<List<SysRolePermissionDTO>> findList(@ModelAttribute SysRolePermissionQueryListCommand sysRolePermissionQueryListCommand){
        return sysRolePermissionApplication.findList(sysRolePermissionQueryListCommand);
    }
    /**
     * describe 分页查询多个角色权限关系
     *
     * @param sysRolePermissionQueryListCommand 分页查询多个角色权限关系     
     * @return {@link Result<LazyPage<SysRolePermissionDTO>>} 分页角色权限关系DTO对象     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "分页查询多个角色权限关系")
    @GetMapping("/findPage")
    public Result<LazyPage<SysRolePermissionDTO>> findPage(@Parameter(description ="分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                           @Parameter(description ="当前页数") @RequestParam(defaultValue = "1", value = "current") int current,@ModelAttribute SysRolePermissionQueryListCommand sysRolePermissionQueryListCommand){
        return sysRolePermissionApplication.findPage(size,current,sysRolePermissionQueryListCommand);
    }
    /**
     * describe 删除角色权限关系
     *
     * @param sysRolePermissionRemoveCommand 删除角色权限关系     
     * @return {@link Result<SysRolePermission>} 角色权限关系     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "删除角色权限关系")
    @DeleteMapping("/remove")
    public Result<SysRolePermission> remove(@ModelAttribute SysRolePermissionRemoveCommand sysRolePermissionRemoveCommand){
        return sysRolePermissionApplication.remove(sysRolePermissionRemoveCommand);
    }
    /**
     * describe 导出角色权限关系
     *
     * @param sysRolePermissionQueryListCommand 导出角色权限关系     
     * @return {@link List<SysRolePermissionExcelExport>} 角色权限关系     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @EasyExcel(fileName = "导出角色权限关系数据")
    @Operation(summary = "导出角色权限关系")
    @GetMapping("/exportExcel")
    public List<SysRolePermissionExcelExport> exportExcel(@ModelAttribute SysRolePermissionQueryListCommand sysRolePermissionQueryListCommand){
        return sysRolePermissionApplication.exportExcel(sysRolePermissionQueryListCommand);
    }
    /**
     * describe 导出模版角色权限关系
     *
     
     * @return {@link Result<List<SysRolePermissionExcelExport>>} 角色权限关系     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @EasyExcel(fileName = "导出角色权限关系模版数据")
    @Operation(summary = "导出角色权限关系模版")
    @GetMapping("/exportTemplateExcel")
    public List<SysRolePermissionExcelExport> exportTemplateExcel(){
        return List.of(new SysRolePermissionExcelExport());
    }
    /**
     * describe 导入角色权限关系
     *
     * @param sysRolePermissionExcelImportList 导入角色权限关系     
     * @return {@link Result<SysRolePermissionExcelImport>} 角色权限关系     
     
     * @author Jia wei Wu
     * @date 2025/08/03 01:55 下午
     **/

    @Operation(summary = "导入角色权限关系")
    @PostMapping("/importExcel")
    public Result<List<SysRolePermissionExcelImport>> importExcel(@RequestExcelBody("multipartFile") List<SysRolePermissionExcelImport> sysRolePermissionExcelImportList){
        return sysRolePermissionApplication.importExcel(sysRolePermissionExcelImportList);
    }
}